package es.uji.viselab.experiment;

import java.awt.Button;
import java.awt.FlowLayout;
import java.awt.Label;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.BoxLayout;
import javax.swing.JComboBox;
import javax.swing.JPanel;

import org.jdesktop.swingx.combobox.EnumComboBoxModel;

import es.uji.viselab.benchmark.BenchMarkingRecorder;
import es.uji.viselab.benchmark.DataPackage;

public class ExperimentCustomizable extends ExperimentInterface   {

	protected Label labelConfiguration = new Label("Control Loop ");
	protected JComboBox availableConfiguration;

	protected Button buttonStart = new Button("Start");
	protected JPanel rootPanel;

	public ExperimentCustomizable(BenchMarkingRecorder bm) {
		super(bm);
		constructPanel();
	}

	public ExperimentCustomizable(ExperimentParameters ep) {
		super(ep);
		constructPanel();
	}

	protected void constructPanel() {

		rootPanel = new JPanel();
		rootPanel.setLayout(new BoxLayout(rootPanel, BoxLayout.PAGE_AXIS));

		availableConfiguration = new JComboBox();
		availableConfiguration.setModel(new EnumComboBoxModel<ExperimentCatalog>(
				ExperimentCatalog.class));
		if (ep.getExperiment() == null) {
			availableConfiguration.setSelectedItem(ExperimentCatalog.CONTROLLOOP_POS200);
			ep.setExperiment(ExperimentCatalog.CONTROLLOOP_POS200);
		} else
			availableConfiguration.setSelectedItem(ep.getExperiment());

		JPanel line1 = new JPanel();
		line1.setLayout(new FlowLayout());
		((FlowLayout) line1.getLayout()).setAlignment(FlowLayout.CENTER);

		line1.add(labelConfiguration);
		line1.add(availableConfiguration);

		JPanel line2 = new JPanel();
		line2.setLayout(new FlowLayout());
		((FlowLayout) line2.getLayout()).setAlignment(FlowLayout.CENTER);
	//	line2.add(buttonLoadFile);
	//	line2.add(buttonCreate);

		JPanel line3 = new JPanel();
		line3.setLayout(new FlowLayout());
		((FlowLayout) line2.getLayout()).setAlignment(FlowLayout.CENTER);
		line3.add(buttonStart);

		buttonStart.addActionListener(this);
		//buttonCreate.addActionListener(this);
		//buttonLoadFile.addActionListener(this);

		rootPanel.add(line1);
		rootPanel.add(line2);
		rootPanel.add(line3);

	}

	public JPanel getPanel() {
		return rootPanel;
	}


	
	

	@Override
	public String getPanelTitle() {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public int panelWidth() {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public int panelHeight() {
		// TODO Auto-generated method stub
		return 0;
	}




	
}
